/**
 * Copyright(c): 2017 com.mjduan All rights reserved.
 * 项目名：learn-spring-web
 * 注意：未经作者允许，不得外传
 */
package com.mjduan.project.util.fastjson;

import com.alibaba.fastjson.JSON;

/**
 * @author mjduan@yahoo.com mjduan 2018-06-24 14:44
 * @version 1.0
 * @since 1.0
 */
public final class FastjsonSerialization {

    private static final FastjsonSerialization INSTANCE = new FastjsonSerialization();

    private FastjsonSerialization() {
    }

    public static FastjsonSerialization getInstance() {
        return INSTANCE;
    }

    public <T> byte[] serialize(T obj) {
        return JSON.toJSONString(obj).getBytes();
    }

    public <T> T deserialize(byte[] data, Class<T> clazz) {
        return JSON.parseObject(data, clazz);
    }
}
